package callnumber.gtdev5.com.photoVault.adapter;

import android.content.Context;
import android.support.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

import callnumber.gtdev5.com.photoVault.R;

public class TypeChoseAdapter extends BaseQuickAdapter<String,BaseViewHolder> {

    private int currentPosition = 0;
    private Context context;

    /**
     * 设置当前选择的item
     * @param currentPosition
     */
    public void setCurrentPosition(int currentPosition) {
        int temp = this.currentPosition;
        this.currentPosition = currentPosition;
        this.notifyItemChanged(temp);
        this.notifyItemChanged(currentPosition);
    }

    public TypeChoseAdapter(@Nullable List<String> data) {
        super(R.layout.su_item_typelayout,data);
    }

    @Override
    protected void convert(BaseViewHolder helper, String item) {
        helper.setText(R.id.tv_type,item);
        if (helper.getAdapterPosition() == currentPosition){
            helper.setImageResource(R.id.iv_icon,R.mipmap.su_xuanzhong);
        }else {
            helper.setImageResource(R.id.iv_icon,R.mipmap.su_weixuanzhong);
        }

    }

    public String getCurentType(){
       if (mData!=null&&mData.size()>currentPosition){
           return mData.get(currentPosition);
       }else {
           return "其他";
       }
    }
}
